/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { HttpSrv } from 'lfun-bg-comp';

export interface UpdateCourse {
  course_id: string;
  course_name: string;
  course_no: string;
  school_id: string;
}

export interface SubjectObject {
  id?: any;
  school_id?: any;
  course_no?: any;
  grade_id?: any;
  course_name?: string;
  subject_name?: string;
  subject_alias?: string;
  subject_level?: string;
  subject_description?: string;
  subject_requirement?: string;
  credit_hour?: number;
  week_credit_hour?: number;
  self_study_credit_hour?: number;
  teach_method?: string;
  textbook_code?: string;
  reference_book?: string;
}

// 查询全部
export const allCourse = () => HttpSrv().get('/school/v1/course/all');
// 课程管理 - 分页查询
export const selectedCourse = (school_id: any, page: number, per_page: number) =>
  HttpSrv().get('/school/v1/course/page', { params: { school_id, page, per_page } });
export const updateCourse = (school_id, course: UpdateCourse[]) =>
  HttpSrv().put(`/school/v1/course/?school_id=${school_id}`, course);
// 课程管理
export const searchSubject = (school_id: any, subject_name: string, page: number, per_page: number) =>
  HttpSrv().get('/school/v1/subject/page', { params: { school_id, subject_name, page, per_page } });

export const createSubject = (params: SubjectObject) => HttpSrv().post('/school/v1/subject/', params);
export const updateSubject = (params: SubjectObject) => HttpSrv().put('/school/v1/subject/', params);
export const delSubject = (id: any) => HttpSrv().delete(`/school/v1/subject/`, { params: { id } });
